<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html lang="zh-cn">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta http-equiv="pragma" content="no-cache">  
		<meta http-equiv="cache-control" content="no-cache">  
		<meta http-equiv="expires" content="0">  
		<title>新增管理员</title>
		<link href="${webroot }/static/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
		<!--时间插件-->
		<link rel="stylesheet" href="${webroot }/static/css/bootstrap-datetimepicker.min.css">
		<!--重置文件-->
		<link rel="stylesheet" href="${webroot }/static/plugins/inputFile/css/style.css" />
		<link rel="stylesheet" href="${webroot }/static/plugins/inputFile/css/ssi-uploader.min.css">
		<link rel="stylesheet" href="${webroot }/static/plugins/icheck/custom.css">
		<link rel="stylesheet" href="${webroot }/static/plugins/icheck/skins/all.css">
		<link rel="stylesheet" href="${webroot }/static/css/reset.css">
		<link rel="stylesheet" href="${webroot }/static/css/merchantGrant.css">
		<jsp:include page="../common/common.jsp"/>
		<style type="text/css">
    	.help-block{
        	float: left;
        	padding-left: 160px;
        }
        .form-group{
        	width:100%!important;
        }
        .has-feedback{
        	width: 480px;
        }
    </style>
	</head>
	<body>
		<section class="content">
			<ol class="breadcrumb">
				<li>管理员管理</li>
				<li class="active">新增管理员信息</li>
			</ol>
			<article id="defaultForm"  class="searchsForm clearfix form-horizontal">
				<form id="addUserForm" method="post" class="form-horizontal">
					<div class="form-group clearfix">
						<div class="col-lg-6 col-md-6">
	                	</div>
						<div class="col-lg-6 col-md-6">
							<a href="javascript:;" id="subButton" class="btn btn-primary w-50 fr" style="margin-left: 10px; margin-right: 10px;" onclick="addUser('addUserForm')">提交</a>
							<a href="javascript:;" onclick="$('#addUserForm')[0].reset()"><input type="text" class="btn btn-primary w-50 fr btn-reset" value="重置"></a>
							<a style="color: #fff;" href="javascript:history.go(-1);"><input  type="text" id="backButton" value="返回上一级" class="btn btn-primary w-50 fr" style="margin-left: 10px;width: 98px !important; margin-right: 10px;"></a>
						</div>
					</div>
					<div class="form-group clearfix">
						<span style="color: red;">注意：带“*”号的都是必填项！</span>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">登录名<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="text" name="loginName" value="" id="loginName" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">登录密码<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="password" name="password" id="password" value="" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">真实姓名<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="text" name="realName" value=""  id="realName" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">所属角色<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<select class="form-control" name="roleId" id="roleId">
							</select>
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">联系电话</label>
						<div class="fl w-300">
							<input type="text" name="telephone" value="" id="telephone" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">手机号<font style="color: red;"> *</font></label>
						<div class="fl w-300">
							<input type="text" name="mobilePhone" value="" id="mobilePhone" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">邮箱</label>
						<div class="fl w-300">
							<input type="text" name="email" value="" id="email" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">联系地址</label>
						<div class="fl w-300">
							<input type="text" name="address" value="" id="address" class="form-control" />
						</div>
						<span class="fl h-34" style="color: gray">联系地址可输入的最大长度50</span>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">邮编</label>
						<div class="fl w-300">
							<input type="text" name="zipCode" value="" id="zipCode" class="form-control" />
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">状态<font style="color: red;"> *</font></label>
		                <div class="fl w-120 posiRE">
		                    <input type="radio" checked="checked"  name="status" value="1"/>
		                    <span>启用</span>
		                </div>
		                <div class="fl w-120 posiRE">
		                    <input type="radio"   name="status" value="2"/>
		                    <span>冻结</span>
		                </div>
					</div>
					<div class="form-group clearfix">
						<label class="fl w-160 control-label">备注&nbsp;&nbsp;</label>
						<div class="fl w-300">
							<input type="text" value="" name="remark" id="remark" class="form-control" />
						</div>
						<span class="fl h-34" style="color: gray">备注可输入的最大长度50</span>
					</div>
				</form>
			</article>
		</section>
<script type="text/javascript">
	$(document).ready(function(){
		getSysRoleDictData("roleId");
	});
	$('input').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
		increaseArea: '20%' // optional
	});
	function addUser(formId){
		var bootstrapValidatorData = $("#" + formId).data('bootstrapValidator');
	    if (bootstrapValidatorData) {
	    	//修复记忆的组件不验证
	    	bootstrapValidatorData.validate();
	        if (!bootstrapValidatorData.isValid()) {
	            return false;
	        }
	    }
	    $.confirm({
			title: false,
			content: '确认新增管理员吗？',
			type:'green',
			autoClose: 'cancle|3000',
			backgroundDismiss: true,
			buttons: {
				ok: {
					btnClass: 'waves-effect waves-button',
					text: '确定',
					action: function(){
						$.ajax({
					        type: "POST",
					        dataType: "json",
					        url: webroot+"/admin/system/addUser",
					        data: $("#" + formId).serialize(),
					        success:function(data){
					        	checkResponseData(data,"1",webroot + "/admin/page/system/userList");
					        },
					        error:function(){
					            $.alert({type:'red',title:"错误", content:"请求新增管理员接口错误，请查找原因！"});
					        }
					    });
					}
				},
				cancle: {
		            text: '取消',
		            btnClass: 'btn-primary',
		            action: function(){
		            	
		            }
		        }
			}
		});
	}
	//用户表单验证规则
	$('#addUserForm').bootstrapValidator({
        feedbackIcons: {/*输入框不同状态，显示图片的样式*/
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {/*验证*/
     	   loginName: {
                validators: {
                	notEmpty: {/*非空提示*/
                        message: '登陆名不能为空'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '请输入字母和数字_ . '
                    },
                    stringLength: {/*长度提示*/
                        min: 3,
                        max: 20,
                        message: '登陆名长度必须在3到20之间'
                    }/*最后一个没有逗号*/
                }
            },
            password: {
                message:'登录密码无效',
                validators: {
                    notEmpty: {
                        message: '登录密码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: '登录密码长度必须在6到30之间'
                    },
                    different: {//不能和用户名相同
                        field: 'loginName',//需要进行比较的input name值
                        message: '不能和登录名相同'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: '登录密码只能输入字母和数字_ . '
                    }
                }
            },
            realName: {
                validators: {
                	notEmpty: {/*非空提示*/
                        message: '真实姓名不能为空'
                    },
                    regexp: {
                        regexp: /^[\u2E80-\u9FFF]+$/,
                        message: '请输入汉字'
                    },
                    stringLength: {/*长度提示*/
                        min: 2,
                        max: 10,
                        message: '真实姓名长度必须在2到10之间'
                    }/*最后一个没有逗号*/
                }
            },
            roleId: {
                validators: {
                    notEmpty: {/*非空提示*/
                        message: '所属角色不能为空'
                    }
                }
            },
            mobilePhone: {
                validators: {
                    notEmpty: {/*非空提示*/
                        message: '手机号不能为空'
                    },
                    regexp: {
                    	 regexp: /^[0-9]{11}$/,
                    	message: '请输入正确手机号'
                   }
                }
            },
            address: {
                validators: {
                    stringLength: {/*长度提示*/
                        min: 0,
                        max: 50,
                        message: '地址长度在0到50之间'
                    }/*最后一个没有逗号*/
                }
            }
        }
    });
</script>
	</body>
	<script type="text/javascript">
		$("#loginName").val("");
		$("#password").val("");
	</script>
</html>
